﻿Imports Telerik.Web.UI
Imports System.Data.SqlClient
Imports System.Data

Partial Class Purchase_LPOHdr
    Inherits System.Web.UI.Page

    Dim _CommandName As String
    Public strConnection As String = ConfigurationManager.ConnectionStrings("DatabaseConnectionString").ConnectionString.ToString

    Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
        Me.Theme = GetGlobalResourceObject("SystemResource", "Theme")
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Dim _lblPageTitle As Label
            _lblPageTitle = Me.Master.FindControl("lblPageTitle")
            _lblPageTitle.Text = GetLocalResourceObject("PageTitle")
        End If
    End Sub

    Protected Sub rgLPOHdr_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles rgLPOHdr.ItemCommand
        _CommandName = e.CommandName

        If e.CommandName = "Add" Then
            e.Canceled = True
            Session("LPOID") = "0"
            Response.Redirect("~/Purchase/LPODtl.aspx?ID=0")
        ElseIf _CommandName = "Edit" Then
            For Each item In rgLPOHdr.MasterTableView.Items
                Dim dataitem As GridDataItem = CType(item, GridDataItem)
                If dataitem.Selected = True Then
                    'CType(Me.Master.FindControl("ToolkitScriptManager1"), RadScriptManager).RegisterPostBackControl(btnSave)
                    e.Canceled = True
                    Response.Redirect("~/Purchase/LPODtl.aspx?ID=" & dataitem("LPOID").Text)
                    Exit Sub
                End If
            Next
        End If

    End Sub

End Class
